home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-06-21 | 2.5 KB | 84 lines | [TEXT/CWIE] |
- /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- *
- * The contents of this file are subject to the Netscape Public License
- * Version 1.0 (the "NPL"); you may not use this file except in
- * compliance with the NPL. You may obtain a copy of the NPL at
- * http://www.mozilla.org/NPL/
- *
- * Software distributed under the NPL is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
- * for the specific language governing rights and limitations under the
- * NPL.
- *
- * The Initial Developer of this code under the NPL is Netscape
- * Communications Corporation. Portions created by Netscape are
- * Copyright (C) 1998 Netscape Communications Corporation. All Rights
- * Reserved.
- */
-
- #pragma mark ---CIntPrefPopup---
- //======================================
- class CIntPrefPopup
- // NOTE: There are two modes of operation: command mode and item mode.
- // Command mode happens if mNumCommands > 0, otherwise item mode obtains.
- // In item mode, unlike the base class LGAPopup, the values are zero based. I.e., the
- // first menu item represents a pref value of zero.
- // In command mode, the command numbers of the items are used for the pref values,
- // allowing the menu items to represent non-consecutive pref values, or reordered
- // pref values.
- //======================================
- : public LGAPopup
- , public MPreference<LControl,int32>
- {
- public:
- CIntPrefPopup(LStream* inStream)
- : LGAPopup(inStream)
- , MPreference<LControl,int32>(this, inStream)
- {
- }
- virtual ~CIntPrefPopup()
- {
- WriteSelf();
- }
- enum { class_ID = 'Ppop' };
- virtual void FinishCreateSelf()
- {
- LGAPopup::FinishCreateSelf();
- MPreferenceBase::FinishCreate();
- }
- virtual int32 GetPaneValue() const
- {
- Int32 itemNumber = LGAPopup::GetValue();
- // Use the command nums, if provided.
- if (mNumCommands > 0)
- return (*mCommandNums)[itemNumber - 1];
- // Otherwise, use the menu item number - 1 (it's zero based).
- return itemNumber - 1;
- }
- virtual void SetPaneValue(int32 inData)
- {
- if (mNumCommands == 0)
- {
- // Item mode.
- LGAPopup::SetValue(inData + 1); // first item's value is zero.
- }
- else
- {
- // Command mode.
- CommandT* cur = *mCommandNums;
- for (int item = 1; item <= mNumCommands; item++, cur++)
- {
- if (*cur == inData)
- {
- SetValue(item);
- break;
- }
- }
- }
- WriteSelf();
- }
- void SetValue ( Int32 value ) { LGAPopup::SetValue(value); WriteSelf(); }
-
- }; // class CIntPrefPopup
-
-